<?php
/**
 * AclAccess form
 *
 * @version $Id: Login.php 73 2010-04-25 00:30:44Z yingkuang.chen@gmail.com $
 * @license New BSD License
 * @uses Zend_Form
 * @package student
 * @subpackage Form
 */
class Default_Form_Login extends Sfs_Form
{

    /**
     * initialization routine
     *
     * @return void
     */
    public function init()
    {
        $param = new Default_Model_ModulesParam();
        $paramArr = $param->getParamByResourceId('default');

        $username = $this->addElement('text', 'username', array(
            'filters'    => array('StringTrim', 'StringToLower'),
            'validators' => array(
                'Alnum',
        array('StringLength', false, array(3, 20)),
        ),
            'required'   => true,
            'label'      => 'Your username:',
        ));

        $password = $this->addElement('password', 'password', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                'Alnum',
        array('StringLength', false, array(6, 20)),
        ),
            'required'   => true,
            'label'      => 'Password:',
        ));

        $login = $this->addElement('submit', 'login', array(
            'required' => false,
            'ignore'   => true,
            'label'    => 'Login',
        ));

        if ($paramArr['captcha'] == 'y') {
            // Add a captcha
            $this->addElement('captcha', 'captcha', array(
            'label'      => 'Please enter the 5 letters displayed below:',
            'required'   => true,
            'captcha' => array(
				'captcha' => 'image',
                'name' => 'foo',
                'wordLen' => 6,
                'font' => Bootstrap::getPath('fonts').'/arial.ttf',
                'fontSize' => 25,
                'imgDir' => Bootstrap::getPath('document').'/cache/captcha',
                'imgUrl' => Zend_Controller_Front::getInstance()->getBaseUrl().'/cache/captcha/',
                'timeout' => 300)
            ));
        }
        $this->addElement('hash', 'csrf', array(
            'ignore' => true,
        ));

        // We want to display a 'failed authentication' message if necessary;
        // we'll do that with the form 'description', so we need to add that
        // decorator.
        $this->setDecorators(array(
            'FormElements',
        array('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')),
        array('Description', array('placement' => 'prepend')),
            'Form'
            ));


    }
}